package kaishi;

import java.util.*;

public class PokerGame {

    static HashMap<Integer,String> hm = new HashMap<>();

    static ArrayList<Integer> list = new ArrayList<>();
    //准备牌
    static {
        String[] color ={"♣","♠","♦","♥"};
        String[] number ={"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
        int nu = 1;
         for (String a : number) {
            for (String s : color) {
                hm.put(nu,s+a);
                list.add(nu);
                nu++;
            }
        }
        hm.put(nu,"大王");
        list.add(nu);
        nu++;
        hm.put(nu,"小王");
        list.add(nu);
    }

     public PokerGame(){
        //打乱牌
        Collections.shuffle(list);
        //发牌
        TreeSet<Integer> dipai = new TreeSet<>();
        TreeSet<Integer> player1 = new TreeSet<>();
        TreeSet<Integer> player2 = new TreeSet<>();
        TreeSet<Integer> player3 = new TreeSet<>();
        for (int i = 0; i < list.size(); i++) {
            int porker = list.get(i);
            if (i<=2){
                dipai.add(porker);
                continue;
            }
            if (i%3==0){
                player1.add(porker);
            }else if (i%3==1){
                player2.add(porker);
            }else{
                player3.add(porker);
            }
        }
        //看牌
        lookPorker("底牌",dipai);
        lookPorker("玩家1",player1);
        lookPorker("玩家2",player2);
        lookPorker("玩家3",player3);
    }
    public void lookPorker(String name,TreeSet<Integer> ts){
        System.out.println(name+"=");
        for (Integer t : ts) {
            String pai = hm.get(t);
            System.out.print(pai+",");
        }
        System.out.println();
    }
}
